package cn.yunhe.services.impl;

import cn.yunhe.dao.ITeacherDao;
import cn.yunhe.entity.Score;
import cn.yunhe.entity.Teacher;
import cn.yunhe.services.ITeacherServices;
import com.github.pagehelper.Page;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2018/6/9.
 */
@Service
public class TeacherServicesImpl implements ITeacherServices {
    @Resource
    private ITeacherDao teacherDao;
    /**
     * 查询符合条件的学生成绩
     * @param map
     * @return
     */
    @Override
    public List<Score> getAll(Map<String, Object> map){
        return teacherDao.getAll(map);
    }

    /**
     * 查询总页数
     * @param map
     * @return
     */
    @Override
    public int getTotalSize(Map<String, Object> map){
        return teacherDao.getTotalSize(map);
    }
    /**
     * 查询出题人
     */
    @Override
    public  List<Teacher> findTeacher(){
        return teacherDao.findTeacher();
    }
    /**
     * 查询登录用户和密码
     * @param map
     * @return
     */
    @Override
    public Teacher findByTeacherName(Map map){
        return teacherDao.findByTeacherName(map);

    }

    @Override
    public Page getStudent(Map<String, Object> map) {

        return teacherDao.getStudent(map);
    }

    @Override
    public Teacher checkLogin(Map map) {
        return teacherDao.checkLogin(map);
    }

/*
    *//**
     * 检查登录
     * @param map
     * @return
     *//*
    @Override
    public Teacher checkLogin(Map map) {
        return teacherDao.findByTeacherName(map);
    }
    *//**
     * 分页查询出题人
     * @param map
     * @return
     *//*
    public Page getStudent(Map<String, Object> map) {
        Page page=new Page();
        //获取当前条件的总页数;
        page.setTotal(teacherDao.getTotalSize(map));
        //获取当前每页有多少数据
        int pageSize=Integer.parseInt(String.valueOf(map.get("pageSize")));
        page.setPageSize(pageSize);
        //获取当前页码
        int pageNum=Integer.parseInt(String.valueOf(map.get("pageNum")));
        page.setPageNum(pageNum);
        //根据条件查询符合的用户列表记录，赋值给page的result变量
        page= PageHelper.startPage(pageNum,pageSize);
        //返回集合
        List<Score> list=teacherDao.getAll(map);
        return page;
    }
    *//**
     * 查看出题人
     *
     * @return
     *//*
    @Override
    public List findTeacher() {
        return teacherDao.findTeacher();
    }*/

}
